from maintenance.utils.bootstrap import BootStrapModelForm
from django import forms
from django.core.validators import RegexValidator
from maintenance import models


class RepairModelForm(BootStrapModelForm):
    phone_number = forms.CharField(
        label="电话号码",
        validators=[RegexValidator(r'^1[3-9]\d{9}$', '手机号格式错误'), ],
    )
    email = forms.CharField(
        label="邮箱",
        validators=[RegexValidator(r'^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$', '邮箱格式错误'), ]
    )

    class Meta:
        model = models.RepairPreorder
        fields = ['name', 'email', 'phone_number', 'car_type', 'date', 'area', 'specific']
